#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: 
@time: 2024/2/27 9:01 PM
@Function: 请输入模块功能描述
"""
import re

from playwright.sync_api import Page, expect, sync_playwright


def test_baidu(page:Page):
    page.goto("http://www.baidu.com")
    #验证被测页面的标题是否包含"百度一下"
    expect(page).to_have_title(re.compile("百度一下"))
    #定义一个locator(搜索框)
    input_text=page.locator("#kw")
    #在搜索框中输入"playwright"
    input_text.fill("playwright")
    get_search=page.locator("text=百度一下")#采用文本定位
    #点击按钮
    get_search.click()


# with sync_playwright() as p:
#     browser=p.chromium.launch(headless = False)#无头模式
#     page=browser.new_page()
#     page.goto("https://www.baidu.com")
#     print(page.title())
#     browser.close()